package com.fengzhi.crawler.jsoup.queue;

import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;

public class ImgQueue {
	// 已下载图像
	private static Set<String> downLoadImgUrl = new HashSet<String>();

	// 未下载图像
	private static Queue<String> unDownLoadImgUrl = new PriorityQueue<String>();

	/**
	 * 
	 * @Title: addDownLoadImgUrl
	 * @Description: TODO(添加已下载图像url)
	 * @author fyf
	 * @param url
	 */
	public static void addDownLoadImgUrl(String url) {
		downLoadImgUrl.add(url);
	}

	/**
	 * 
	 * @Title: removeDownLoadImgUrl
	 * @Description: TODO(删除已下载图像url)
	 * @author fyf
	 * @param url
	 */
	public static void removeDownLoadImgUrl(String url) {
		downLoadImgUrl.remove(url);
	}

	/**
	 * 
	 * @Title: getDownLoadImgUrl
	 * @Description: TODO(已访问下载url集合)
	 * @author fyf
	 * @return
	 */
	public static Set<String> getDownLoadImgUrl() {
		return downLoadImgUrl;
	}

	/**
	 * 
	 * @Title: getDownLoadImgUrlSize
	 * @Description: TODO(已访问下载url集合数量)
	 * @author fyf
	 * @return
	 */
	public static int getDownLoadImgUrlSize() {
		return downLoadImgUrl.size();
	}

	/**
	 * 
	 * @Title: unDownLoadImgUrlDeQueue
	 * @Description: TODO(检索取出未下载图像url，并从队列中删除)
	 * @author fyf
	 * @return
	 */
	public static String  unDownLoadImgUrlDeQueue() {
		return unDownLoadImgUrl.poll();
	}

	/**
	 * 
	 * @Title: addDownLoadImgUrlDeQueue
	 * @Description: TODO(添加未下载图像url)
	 * @author fyf
	 * @param url
	 */
	public static void addUnDownLoadImgUrl(String url) {
		if (url != null && "".equals(url) && !downLoadImgUrl.contains(url) && !unDownLoadImgUrl.contains(url)) {
			unDownLoadImgUrl.add(url);
		}
	}

	/**
	 * 
	 * @Title: unDownLoadImgUrlIsEmpty
	 * @Description: TODO(未下载图像url是否为空)
	 * @author fyf
	 * @return
	 */
	public static boolean unDownLoadImgUrlIsEmpty() {
		return unDownLoadImgUrl.isEmpty();
	}

	/**
	 * 
	 * @Title: getUnDownLoadImgUrlSize
	 * @Description: TODO(未访问下载图像url)
	 * @author fyf
	 * @return
	 */
	public static int getUnDownLoadImgUrlSize() {
		return unDownLoadImgUrl.size();
	}
}
